import util from "@/libs/util";

export default ({ request }) => ({
  /**
   * @description 收货地址列表
   */
  ADDR_LIST() {
    let userinfo = util.store.getItem("userinfo");
    return request({
      url: "/data/v1/addressList",
      method: "post",
      data: {
        id: userinfo.user_id,
      },
    });
  },
  /**
   * @description 添加收货地址
   * @param {*} data
   * @returns
   */
  ADDR_ADD(data = {}) {
    let userinfo = util.store.getItem("userinfo");
    data.id = userinfo.user_id;
    return request({
      url: "/data/v1/addressAdd",
      method: "post",
      data: data,
    });
  },
  /**
   * @description 编辑收货地址
   * @param {*} data
   * @returns
   */
  ADDR_EDIT(data = {}) {
    return request({
      url: "/data/v1/addressEdit",
      method: "post",
      data: data,
    });
  },
  /**
   * @description 编辑收货地址
   * @param {*} data
   * @returns
   */
  ADDR_DEL(id) {
    return request({
      url: "/data/v1/addressDelete",
      method: "post",
      data: { id },
    });
  },
});
